export function downloadFromResponse(response,fileName){

  // request({
  //   url: '/equipment/report/downloadFile?id=' + id,
  //   method: 'get',
  //   responseType: 'blob'
  // }).then(response => {
  //
  // })


  let blob = new Blob([response]) // 转成文本存储
  let a = document.createElement('a') // 转换完成，创建一个a标签用于下载

  if (fileName !== null) {
    a.download = fileName
  } else {
    let s = response.getHeaders()['content-disposition']
    a.download = decodeURI(s.split('filename=')[1])
  }

  a.href = window.URL.createObjectURL(blob) // 转成本地连接到blob文本
  a.click()

}
